
// <copyright file="GenericFilterMethodStrategy.cs" company="Subhadra Software Solutions">
//   
// </copyright>
// <summary>
//   The generic filter method strategy.
// </summary>

namespace SubhadraSolutions.Sharp.Utils.Diagnostics.Performance
{
    using System;
    using System.Collections.Generic;
    using System.Reflection;

    using SubhadraSolutions.Sharp.Utils.Reflection;

    /// <summary>
    /// The generic filter method strategy.
    /// </summary>
    /// <typeparam name="T">
    /// </typeparam>
    public sealed class GenericFilterMethodStrategy<T> : IFilterMethodsStrategy<T>
        where T : Attribute
    {
        #region Static Fields

        /// <summary>
        /// The instance.
        /// </summary>
        private static readonly GenericFilterMethodStrategy<T> InstanceObject = new GenericFilterMethodStrategy<T>();

        #endregion Static Fields

        #region Constructors and Finalizers

        /// <summary>
        /// Prevents a default instance of the <see cref="GenericFilterMethodStrategy"/> class from being created. 
        /// Prevents a default instance of the <see cref="GenericFilterMethodStrategy{T}"/> class from being created.
        /// </summary>
        private GenericFilterMethodStrategy()
        {
        }

        #endregion Constructors and Finalizers

        #region Public Properties

        /// <summary>
        /// Gets the instance.
        /// </summary>
        public static GenericFilterMethodStrategy<T> Instance
        {
            get
            {
                return InstanceObject;
            }
        }

        /// <summary>
        /// Gets or sets the do not inject attribute type.
        /// </summary>
        public Type DoNotInjectAttributeType { get; set; }

        #endregion Public Properties

        #region Public Methods and Operators

        /// <summary>
        /// The filter methods.
        /// </summary>
        /// <param name="assembly">
        /// The assembly.
        /// </param>
        /// <returns>
        /// The <see cref="IEnumerable"/>.
        /// </returns>
        public IEnumerable<InjectableMethodInfo<T>> FilterMethods(Assembly assembly)
        {
            return MethodUtil.GetInjectableMethods<T>(assembly, this.DoNotInjectAttributeType);
        }

        #endregion Public Methods and Operators
    }
}